package com.imut.lagain.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.imut.lagain.entity.SystemNotification;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 系统通知服务接口
 */
public interface SystemNotificationService {
    
    /**
     * 创建通知
     */
    SystemNotification createNotification(Long receiverId, Long triggerUserId, 
                                         String notificationType, String title, 
                                         String content, Long resourceId, 
                                         String resourceType, Integer priority);
    
    /**
     * 创建胶囊创建通知
     */
    SystemNotification createCapsuleCreatedNotification(Long receiverId, Long triggerUserId, 
                                                       Long capsuleId, String capsuleTitle);
    
    /**
     * 创建胶囊打开通知
     */
    SystemNotification createCapsuleOpenedNotification(Long receiverId, Long triggerUserId, 
                                                      Long capsuleId, String capsuleTitle);
    
    /**
     * 创建小偷偷取成功通知
     */
    SystemNotification createThiefSuccessNotification(Long receiverId, Long triggerUserId, 
                                                     Long resourceId, String resourceType);
    
    /**
     * 创建小偷偷取失败通知
     */
    SystemNotification createThiefFailedNotification(Long receiverId, Long triggerUserId, 
                                                    Long resourceId, String resourceType);
    
    /**
     * 创建伴侣绑定通知
     */
    SystemNotification createPartnerBoundNotification(Long receiverId, Long partnerId);
    
    /**
     * 创建心情分享通知
     */
    SystemNotification createMoodSharedNotification(Long receiverId, Long triggerUserId, 
                                                   Long moodId);
    
    /**
     * 创建回忆创建通知
     */
    SystemNotification createMemoryCreatedNotification(Long receiverId, Long triggerUserId, 
                                                      Long memoryId, String memoryTitle);
    
    /**
     * 创建信件接收通知
     */
    SystemNotification createLetterReceivedNotification(Long receiverId, Long triggerUserId, 
                                                       Long letterId);
    
    /**
     * 创建生理期提醒通知
     */
    SystemNotification createPeriodReminderNotification(Long receiverId, String reminderType);
    
    /**
     * 创建系统更新通知
     */
    SystemNotification createSystemUpdateNotification(Long receiverId, String updateContent);
    
    /**
     * 获取用户通知列表（分页）
     */
    IPage<SystemNotification> getUserNotifications(Long userId, int page, int size);
    
    /**
     * 获取用户未读通知数量
     */
    Long getUnreadNotificationCount(Long userId);
    
    /**
     * 获取用户指定类型的通知
     */
    List<SystemNotification> getNotificationsByType(Long userId, String type);
    
    /**
     * 获取用户未读的指定类型通知
     */
    List<SystemNotification> getUnreadNotificationsByType(Long userId, String type);
    
    /**
     * 标记通知为已读
     */
    boolean markAsRead(Long notificationId, Long userId);
    
    /**
     * 批量标记用户所有通知为已读
     */
    boolean markAllAsRead(Long userId);
    
    /**
     * 批量标记指定类型的通知为已读
     */
    boolean markTypeAsRead(Long userId, String type);
    
    /**
     * 删除通知（软删除）
     */
    boolean deleteNotification(Long notificationId, Long userId);
    
    /**
     * 获取指定时间范围内的通知
     */
    List<SystemNotification> getNotificationsByTimeRange(Long userId, 
                                                        LocalDateTime startTime, 
                                                        LocalDateTime endTime);
    
    /**
     * 获取高优先级未读通知
     */
    List<SystemNotification> getHighPriorityUnreadNotifications(Long userId, Integer minPriority);
    
    /**
     * 根据资源ID和类型查找通知
     */
    List<SystemNotification> getNotificationsByResource(Long resourceId, String resourceType);
    
    /**
     * 获取触发者相关的通知
     */
    List<SystemNotification> getNotificationsByTriggerUser(Long triggerUserId);
    
    /**
     * 获取通知详情
     */
    SystemNotification getNotificationById(Long notificationId, Long userId);
    
    /**
     * 清理过期通知
     */
    int cleanExpiredNotifications(int days);
    
    /**
     * 获取用户通知统计
     */
    Map<String, Object> getNotificationStatistics(Long userId);
    
    /**
     * 获取用户最近的通知摘要
     */
    List<Map<String, Object>> getNotificationSummary(Long userId, int days);
    
    /**
     * 验证用户是否有权限访问通知
     */
    boolean hasPermission(Long notificationId, Long userId);
    
    /**
     * 批量创建通知
     */
    List<SystemNotification> createBatchNotifications(List<Long> receiverIds, 
                                                     Long triggerUserId, 
                                                     String notificationType, 
                                                     String title, String content, 
                                                     Long resourceId, String resourceType, 
                                                     Integer priority);
    
    /**
     * 获取用户今日通知数量
     */
    Long getTodayNotificationCount(Long userId);
    
    /**
     * 推送实时通知
     */
    void pushRealTimeNotification(SystemNotification notification);
}